package edu.gatech.cc.hwa.server.features;

import edu.gatech.cc.hwa.server.Profile;

public class TimeToTypePasswordFeature extends Feature{
	
	private static final double leeway = 2.0;
	
	private final int time;
	
	public TimeToTypePasswordFeature(String passWordTime){
		super(passWordTime);
		time = Integer.parseInt(passWordTime);
	}
	
	public int getTime() {
		return time;
	}

	@Override
	public boolean matchesProfile(Profile profile) {
		if (time < 0) {return true;}
		int profileTimeToType = profile.getTimeToTypePassword();
		return profileTimeToType <= (double)(time*leeway) && profileTimeToType >= (double)(time/leeway);
	}
}
